package ru.aslanov.schedule.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

/**
 * Created by IntelliJ IDEA.
 * Created: Feb 11, 2010 6:03:47 PM
 *
 * @author Sergey Aslanov
 */
public interface ScheduleServices extends RemoteService {
    void publishSchedule(String scheduleKey) throws Exception;

    void unpublishSchedule(String scheduleKey) throws Exception;

    UserData getUserData();

    void loadFromGCalendar(String scheduleKey) throws Exception;

    void publishToGCalendar(String scheduleKey) throws Exception;

    void removeAuthorization(String scheduleKey) throws Exception;

    void postXmlToUrl(String scheduleKey) throws Exception;

    String getXml(String scheduleKey, String lang) throws Exception;

    void syncGroupDays() throws Exception;

    void clearMemCache() throws Exception;

    /**
     * Utility/Convenience class.
     * Use ScheduleServices.App.getInstance() to access static instance of ScheduleServicesAsync
     */
    public static class App {
        private static final ScheduleServicesAsync ourInstance;

        static {
            ourInstance = (ScheduleServicesAsync) GWT.create(ScheduleServices.class);
            ((ServiceDefTarget) ourInstance).setServiceEntryPoint(GWT.getModuleBaseURL() + "ru.aslanov.schedule.schedule/ScheduleServices");
        }

        public static ScheduleServicesAsync getInstance() {
            return ourInstance;
        }
    }
}
